﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="negotiation.aspx.cs" Inherits="negotiation" culture="auto" meta:resourcekey="PageResource1" uiculture="auto" %>

<script runat="server">
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <div id="view">
        <h2 style=" vertical-align:middle;">新增交涉</h2>

        <table style=" margin:10px 0 auto; padding:0px; border: 1px solid; left:0px;">
            <tr>
                <td> <asp:Label ID="Label14" runat="server" Text="交涉人" 
            ></asp:Label></td>
                <td><asp:TextBox ID="MNameTextBox" runat="server" ReadOnly="True" Enabled="False" 
            ></asp:TextBox></td>
            </tr>


            <tr>
                <td> <asp:Label ID="Label19" runat="server" Text="通緝令編號" 
            ></asp:Label></td>
                <td>  <asp:TextBox ID="WIdTextBox" runat="server" 
            Enabled="False"></asp:TextBox></td>
            </tr>

            <tr>
                <td><asp:Label ID="Label15" runat="server" Text="發布日期" 
            ></asp:Label></td>
                <td> <asp:TextBox ID="NDateTextBox" runat="server" ReadOnly="True" Enabled="False" 
            ></asp:TextBox></td>
            </tr>

            <tr>
                <td> <asp:Label ID="Label17" runat="server" Text="預定出貨日期"></asp:Label></td>
                <td> <asp:TextBox ID="NDealDateTextBox" runat="server" ReadOnly="True" ontextchanged="NDealDateTextBox_TextChanged" 
            ></asp:TextBox></td>
            </tr>


            <tr>
                <td colspan='3' rowspan='2'>
                    <asp:Calendar ID="NDealDateCalendar" runat="server" BackColor="White" 
                        BorderColor="White" BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" 
                        ForeColor="Black" Height="190px" NextPrevFormat="FullMonth" 
                        onselectionchanged="NDealDateCalendar_SelectionChanged" Width="350px">
                        <DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
                        <NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333" 
                            VerticalAlign="Bottom" />
                        <OtherMonthDayStyle ForeColor="#999999" />
                        <SelectedDayStyle BackColor="#333399" ForeColor="White" />
                        <TitleStyle BackColor="White" BorderColor="Black" BorderWidth="4px" 
                            Font-Bold="True" Font-Size="12pt" ForeColor="#333399" />
                        <TodayDayStyle BackColor="#CCCCCC" />
                    </asp:Calendar>
                </td>
            </tr>


            <tr>
                <td> 
            <asp:RequiredFieldValidator ID="NDealDateRequiredFieldValidator" runat="server" 
            ControlToValidate="NDealDateTextBox" ErrorMessage="* 必須選擇出貨日期"></asp:RequiredFieldValidator>
                    <br />
                    <asp:RangeValidator ID="NDealDateRangeValidator" runat="server" 
            ControlToValidate="NDealDateTextBox" ErrorMessage="* 必須設定為今天之後.(含今天)"></asp:RangeValidator></td>
            </tr>


            <tr>
                <td><asp:Label ID="Label20" runat="server" Text="買家預算" 
            ></asp:Label></td>
                <td><asp:TextBox ID="WGBudgetTextBox" runat="server" Enabled="False" 
            ></asp:TextBox></td>
            </tr>

            <tr>
                <td><asp:Label ID="Label1" runat="server" Text="商品名稱"></asp:Label></td>
                <td><asp:TextBox ID="NGNameTextBox" runat="server" Enabled="False"></asp:TextBox></td>
                <td colspan='2'><asp:RequiredFieldValidator ID="NGNameRequiredFieldValidator" runat="server" 
            ControlToValidate="NGNameTextBox" ErrorMessage="* 商品名稱不得為空" 
            ></asp:RequiredFieldValidator></td>
            </tr>


            <tr>
                <td><asp:Label ID="Label18" runat="server" Text="商品種類" 
            ></asp:Label></td>
                <td><asp:DropDownList ID="GCIdDropDownList" runat="server" 
            DataSourceID="SqlDataSource1" DataTextField="GCthird" 
            DataValueField="GCId" meta:resourcekey="GCIdDropDownListResource1" Enabled="False">
        </asp:DropDownList></td>
            </tr>


            <tr>
                <td><asp:Label ID="Label7" runat="server" Text="商品數量"></asp:Label></td>
                    <td> <asp:TextBox ID="NGAmountTextBox" runat="server"></asp:TextBox></td>
                <td>
                    <asp:RangeValidator ID="NGAmountRangeValidator" runat="server" 
                        ControlToValidate="NGAmountTextBox" ErrorMessage="* 數量必須大於 0" 
                        MaximumValue="65535" MinimumValue="1" SetFocusOnError="True" 
                        Type="Integer" meta:resourcekey="WGAmountRangeValidatorResource1"></asp:RangeValidator>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="NGAmountRequiredFieldValidator" 
                runat="server" ControlToValidate="NGAmountTextBox" ErrorMessage="* 數量不得為空"></asp:RequiredFieldValidator>
                </td>
            </tr>


            <tr>
                <td><asp:Label ID="Label13" runat="server" Text="出價"></asp:Label></td>
                <td><asp:TextBox ID="NGBudgetTextBox" runat="server" 
            ></asp:TextBox></td>
                <td> 
                    <asp:RangeValidator ID="NGBudgetRangeValidator" runat="server" 
                ControlToValidate="NGBudgetTextBox" ErrorMessage="* 金額必須大於 0" MinimumValue="1" 
                Type="Integer" MaximumValue="int.MaxValue"></asp:RangeValidator>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="NGBudgetRequiredFieldValidator" 
            runat="server" ControlToValidate="NGBudgetTextBox" ErrorMessage="* 金額不得為空"></asp:RequiredFieldValidator>
                </td>
            </tr>

            <tr>
                <td><asp:Label ID="Label3" runat="server" Text="商品年份"></asp:Label></td>
                <td><asp:TextBox ID="NGYearTextBox" runat="server"></asp:TextBox></td>
                <td colspan='2'>
                    <asp:RangeValidator ID="NGYearTextBoxRangeValidator" runat="server" 
            ControlToValidate="NGYearTextBox" ErrorMessage="* 西元年份必須介於1~今年"></asp:RangeValidator></td>
            </tr>

            <tr>
                <td><asp:Label ID="Label8" runat="server" Text="月份" 
            ></asp:Label></td>
                <td><asp:DropDownList ID="NGMonthTextBoxDropDownList" runat="server" 
            >
            <asp:ListItem Value="1" meta:resourcekey="ListItemResource1">1月</asp:ListItem>
            <asp:ListItem Value="2" meta:resourcekey="ListItemResource2">2月</asp:ListItem>
            <asp:ListItem Value="3" meta:resourcekey="ListItemResource3">3月</asp:ListItem>
            <asp:ListItem Value="4" meta:resourcekey="ListItemResource4">4月</asp:ListItem>
            <asp:ListItem Value="5" meta:resourcekey="ListItemResource5">5月</asp:ListItem>
            <asp:ListItem Value="6" meta:resourcekey="ListItemResource6">6月</asp:ListItem>
            <asp:ListItem Value="7" meta:resourcekey="ListItemResource7">7月</asp:ListItem>
            <asp:ListItem Value="8" meta:resourcekey="ListItemResource8">8月</asp:ListItem>
            <asp:ListItem Value="9" meta:resourcekey="ListItemResource9">9月</asp:ListItem>
            <asp:ListItem Value="10" meta:resourcekey="ListItemResource10">10月</asp:ListItem>
            <asp:ListItem Value="11" meta:resourcekey="ListItemResource11">11月</asp:ListItem>
            <asp:ListItem Value="12" meta:resourcekey="ListItemResource12">12月</asp:ListItem>
        </asp:DropDownList></td>
            </tr>

            <tr>
                <td> <asp:Label ID="Label4" runat="server" Text="商品國籍/產地" 
            ></asp:Label></td>
                <td><asp:TextBox ID="NGMadeInTextBox" runat="server" 
            >台灣</asp:TextBox></td>
            <td colspan='2'><asp:RequiredFieldValidator ID="NGMadeInRequiredFieldValidator" runat="server" 
            ControlToValidate="NGMadeInTextBox" ErrorMessage="* 必須輸入產地"></asp:RequiredFieldValidator></td>
            </tr>

            <tr>
                <td><asp:Label ID="Label9" runat="server" Text="商品品牌(選填)" 
            ></asp:Label></td>
                <td><asp:TextBox ID="NGBrandTextBox" runat="server" 
            ></asp:TextBox></td>
            </tr>

            <tr>
                <td> <asp:Label ID="Label10" runat="server" Text="商品圖片"></asp:Label></td>
                <td> <asp:FileUpload ID="PictureFileUpload" runat="server" /></td>
            </tr>

             <tr>
                <td> <asp:Label ID="Label11" runat="server" Text="特殊用途(選填)" 
            ></asp:Label></td>
                <td> <asp:TextBox ID="NGAppTextBox" runat="server" 
            meta:resourcekey="NGAppTextBoxResource1"></asp:TextBox></td>
            </tr>

             <tr>
                <td><asp:Label ID="Label12" runat="server" Text="商品外觀描述(選填)"></asp:Label></td>
                <td><asp:TextBox ID="NGDescriptionTextBox" runat="server" 
            ></asp:TextBox></td>
            </tr>

            <tr>
                <td><asp:Label ID="Label16" runat="server" Text="指定的交易方式"></asp:Label></td>
                <td> <asp:ListBox ID="NTranListBox" runat="server" SelectionMode="Multiple" 
                    ToolTip="(按 Ctrl 鍵 可以複選交易的方式)" meta:resourcekey="WTranListBoxResource1">
                    <asp:ListItem >面交</asp:ListItem>
                    <asp:ListItem >超商取貨</asp:ListItem>
                    <asp:ListItem >宅配</asp:ListItem>
                    </asp:ListBox>
                </td>
                <td colspan='2'> <asp:RequiredFieldValidator ID="NTranListBoxRequiredFieldValidator" 
            runat="server" ControlToValidate="NTranListBox" ErrorMessage="* 必須指定交易的方式"></asp:RequiredFieldValidator></td>
            </tr>
           
             <tr>
                <td> <asp:Button ID="SubmitButton" runat="server" Text="進行交涉" 
            onclick="SubmitButton_Click" style="height: 21px" /></td>
            </tr>
            
        </table>
        
        
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:projectConnectionString %>" 
            SelectCommand="SELECT [GCId], [GCthird] FROM [GoodsCategory] WHERE ([GCthird] = @GCthird)">
            <SelectParameters>
                <asp:SessionParameter Name="GCthird" SessionField="GCthird" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
 
        <br />
       
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:projectConnectionString %>" 
            SelectCommand="SELECT * FROM [Negotiation] WHERE ([MId] = @MId)">
            <SelectParameters>
                <asp:SessionParameter Name="MId" SessionField="MId" />
            </SelectParameters>
        </asp:SqlDataSource>
        <br />
        <asp:ListView ID="GoodsPicListView" runat="server">
        </asp:ListView>
        <br />
        <asp:SqlDataSource ID="GCPic" runat="server" 
            ConnectionString="<%$ ConnectionStrings:projectConnectionString %>" 
            SelectCommand="SELECT * FROM [GoodsPic]" 
            DeleteCommand="DELETE FROM [GoodsPic] WHERE [GPId] = @GPId" 
            InsertCommand="INSERT INTO [GoodsPic] ([GPServName], [GPName], [GPNote]) VALUES (@GPServName, @GPName, @GPNote)" 
            
            UpdateCommand="UPDATE [GoodsPic] SET [GPServName] = @GPServName, [GPName] = @GPName, [GPNote] = @GPNote WHERE [GPId] = @GPId">
            <DeleteParameters>
                <asp:Parameter Name="GPId" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="GPServName" Type="String" />
                <asp:Parameter Name="GPName" Type="String" />
                <asp:Parameter Name="GPNote" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="GPServName" Type="String" />
                <asp:Parameter Name="GPName" Type="String" />
                <asp:Parameter Name="GPNote" Type="String" />
                <asp:Parameter Name="GPId" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <br />
    </div>
</asp:Content>

